---
import {type CollectionEntry, getCollection} from "astro:content";
import BlogPost from "../../layouts/BlogPost.astro";
import {filterPosts} from "../../utils/misc";

export async function getStaticPaths() {
  const posts = filterPosts(await getCollection("blog"), {
    filterDraft: true,
    filterUnlisted: false,
  });
  return posts.map((post) => ({
    params: {slug: post.slug},
    props: {post, posts},
  }));
}
// type Props = CollectionEntry<'blog'>;

const {post, posts} = Astro.props;
const {Content} = await post.render();
---

<BlogPost posts={posts} {...post.data}>
  <Content />
</BlogPost>
